package com.zxy.car.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zxy.common.utils.PageUtils;
import com.zxy.common.utils.Query;

import com.zxy.car.dao.LuDao;
import com.zxy.car.entity.LuEntity;
import com.zxy.car.service.LuService;


@Service("luService")
public class LuServiceImpl extends ServiceImpl<LuDao, LuEntity> implements LuService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<LuEntity> wrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        String key1 = (String) params.get("key1");
        String key2 = (String) params.get("key2");
        if (StringUtils.isNotEmpty(key)){
            wrapper.and(w->{
                w.like("name",key);
            });
        }
        if (StringUtils.isNotEmpty(key1)){
            wrapper.and(w->{
                w.gt("price",key1);
            });
        }
        if (StringUtils.isNotEmpty(key2)){
            wrapper.and(w->{
                w.lt("price",key2);
            });
        }

        IPage<LuEntity> page = this.page(
                new Query<LuEntity>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }

}